var ZDWindow=Class.create();
ZDWindow.prototype = {
  initialize: function() {
    this.options = Object.extend({
      title:  "dialog",
      content: "content",
    }, arguments[0] || {});
  },
  _createWindow: function() {
    this.win = new Element('div', { id: 'foo',tabindex:"-1" });
    this.win.addClassName("ui-dialog ui-widget ui-widget-content ui-corner-all  ui-draggable ui-resizable");
    this.win.setStyle({
      outline: "0px none" ,
      position: "absolute", 
      height: "auto", 
      width: "300px", 
      top: "391px", 
      left: "575px" });
    //add title bar
    this.titlebar = new Element("div");
    this.titlebar.addClassName("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix");
    this.titlebar.update("<span class='ui-dialog-title'>"+this.options.title+"</span>");
    var closeButton=new Element("a" , {href:"#"});
    closeButton.addClassName("ui-dialog-titlebar-close ui-corner-all");
    closeButton.update("<span class='ui-icon ui-icon-closethick'>close</span>");
    this.titlebar.insert({bottom:closeButton});
    this.win.insert({top: this.titlebar});

    var content=new Element("div");
    content.addClassName("ui-dialog-content ui-widget-content");
    content.setStyle({width: "auto", display: "block", minHeight: "200px", height: "auto"});
    content.update(this.options.content);
    this.win.insert({bottom: content});

    this.win.insert({bottom: new Element("div").addClassName("ui-resizable-handle ui-resizable-n")});
    this.win.insert({bottom: new Element("div").addClassName("ui-resizable-handle ui-resizable-e")});
    this.win.insert({bottom: new Element("div").addClassName("ui-resizable-handle ui-resizable-s")});
    this.win.insert({bottom: new Element("div").addClassName("ui-resizable-handle ui-resizable-w")});

    var se=new Element("div");
    se.addClassName("ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se ui-icon-grip-diagonal-se" );
    this.win.insert({bottom: se});

    this.win.insert({bottom: new Element("div").addClassName("ui-resizable-handle ui-resizable-sw")});
    this.win.insert({bottom: new Element("div").addClassName("ui-resizable-handle ui-resizable-ne")});
    this.win.insert({bottom: new Element("div").addClassName("ui-resizable-handle ui-resizable-nw")});

    Element.hide(this.win);
    var body=$(document.body);
    body.insert({ top: this.win});
  },
  show: function() {
    this._createWindow();
    this.win.show();
  },
  setHeight: function(height) {
    this.height = height;
  },
  setWidth: function(width) {
    this.width = width;
  },
  setContent:function(content) {
    this.content = content;
  }
}

